package com.ysxsoft.wdg.ui.activity.my;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.ysxsoft.wdg.R;
import com.ysxsoft.wdg.base.BaseActivity;
import com.ysxsoft.wdg.bean.BaseBean;
import com.ysxsoft.wdg.bean.UserInfoBean;
import com.ysxsoft.wdg.net.CallbackCode;
import com.ysxsoft.wdg.util.ToastUtils;
import com.ysxsoft.wdg.widget.alertview.AlertViewFactory;

import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import retrofit2.Retrofit;

public class MyKfActivity extends BaseActivity {


    private String phone;

    public static void start(Context context){
        Intent intent = new Intent(context,MyKfActivity.class);
        context.startActivity(intent);
    }


    @BindView(R.id.topView)
    View topView;
    @BindView(R.id.title_content)
    TextView titleContent;
    @BindView(R.id.tv_mobie)
    TextView tvMobie;
    @BindView(R.id.tv_wx)
    TextView tvWx;
    @BindView(R.id.tv_qq)
    TextView tvQq;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_kf;
    }

    @Override
    protected void initData() {
        initStatusBar(topView,false);
        titleContent.setText("我的客服");

        mApiHelper.getKf(new Observer<BaseBean<UserInfoBean>>() {
            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(BaseBean<UserInfoBean> baseBean) {

                if (baseBean.getCode().equals(CallbackCode.SUCCESS)){
                    UserInfoBean infoBean = baseBean.getData();
                    phone = infoBean.getPhone();
                    tvMobie.setText(phone);
                    tvWx.setText(infoBean.getWechat());
                    tvQq.setText(infoBean.getQq());

                }else {
                    ToastUtils.showToast(baseBean.getMs());
                }

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    protected void setListener() {

    }


    @OnClick({R.id.title_finish, R.id.ll_mobie, R.id.ll_wx, R.id.ll_qq, R.id.ll_tel})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_finish:
                finish();
                break;
            case R.id.ll_mobie:
                break;
            case R.id.ll_wx:
                break;
            case R.id.ll_qq:
                break;
            case R.id.ll_tel://联系客服
                if (TextUtils.isEmpty(phone)){
                    ToastUtils.showToast("请稍后再试");
                    return;
                }
                AlertViewFactory.getInstance().getCallAlert(mContext,phone).show();
                break;
        }
    }
}
